
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       fms_param.c
  * @author     baiyang
  * @date       2023-7-6
  ******************************************************************************
  */

/*----------------------------------include-----------------------------------*/
#include "fms.h"

#include <parameter/param.h>
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/

/*---------------------------------prototype----------------------------------*/

/*----------------------------------variable----------------------------------*/
static param_t var_info[] = {
    PARAM_DEFINE_INT16(FORMAT_VERSION, 0),

    // @Param: THR_MIN
    // @DisplayName: Minimum Throttle
    // @Description: Minimum throttle percentage used in all modes except manual, provided THR_PASS_STAB is not set. Negative values allow reverse thrust if hardware supports it.
    // @Units: %
    // @Range: -100 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(THR_MIN,THROTTLE_MIN),

    // @Param: THR_MAX
    // @DisplayName: Maximum Throttle
    // @Description: Maximum throttle percentage used in all modes except manual, provided THR_PASS_STAB is not set.
    // @Units: %
    // @Range: 0 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(THR_MAX,THROTTLE_MAX),

    // @Param: THR_SLEWRATE
    // @DisplayName: Throttle slew rate
    // @Description: Maximum change in throttle percentage per second. Lower limit  based on 1 microsend of servo increase per loop. Divide SCHED_LOOP_RATE by approximately 10 to determine minimum achievable value.
    // @Units: %/s
    // @Range: 0 127
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(THR_SLEWRATE,100),

    // @Param: TRIM_THROTTLE
    // @DisplayName: Throttle cruise percentage
    // @Description: Target percentage of throttle to apply for flight in automatic throttle modes and throttle percentage that maintains TRIM_ARSPD_CM. Caution: low battery voltages at the end of flights may require higher throttle to maintain airspeed.
    // @Units: %
    // @Range: 0 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(TRIM_THROTTLE,THROTTLE_CRUISE),

    // @Param: TKOFF_THR_MAX
    // @DisplayName: Maximum Throttle for takeoff
    // @Description: The maximum throttle setting during automatic takeoff. If this is zero then THR_MAX is used for takeoff as well.
    // @Units: %
    // @Range: 0 100
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(TKOFF_THR_MAX,0),

    // @Param: ARSPD_FBW_MIN
    // @DisplayName: Minimum Airspeed
    // @Description: Minimum airspeed demanded in automatic throttle modes. Should be set to 20% higher than level flight stall speed.
    // @Units: m/s
    // @Range: 5 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT16(ARSPD_FBW_MIN,  AIRSPEED_FBW_MIN),

    // @Param: ARSPD_FBW_MAX
    // @DisplayName: Maximum Airspeed
    // @Description: Maximum airspeed demanded in automatic throttle modes. Should be set slightly less than level flight speed at THR_MAX and also at least 50% above ARSPD_FBW_MIN to allow for accurate TECS altitude control.
    // @Units: m/s
    // @Range: 5 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT16(ARSPD_FBW_MAX, AIRSPEED_FBW_MAX),

    // @Param: TRIM_ARSPD_CM
    // @DisplayName: Target airspeed
    // @Description: Target airspeed in cm/s in automatic throttle modes. Value is as an indicated (calibrated/apparent) airspeed.
    // @Units: cm/s
    // @User: Standard
    PARAM_DEFINE_INT32(TRIM_ARSPD_CM,  AIRSPEED_CRUISE_CM),

    // @Param: MIN_GNDSPD_CM
    // @DisplayName: Minimum ground speed
    // @Description: Minimum ground speed in cm/s when under airspeed control
    // @Units: cm/s
    // @User: Advanced
    PARAM_DEFINE_INT32(MIN_GNDSPD_CM,  MIN_GNDSPEED_CM),

    // @Param: CRASH_DETECT
    // @DisplayName: Crash Detection
    // @Description: Automatically detect a crash during AUTO flight and perform the bitmask selected action(s). Disarm will turn off motor for safety and to help against burning out ESC and motor. Set to 0 to disable crash detection.
    // @Values: 0:Disabled
    // @Bitmask: 0:Disarm
    // @User: Advanced
    PARAM_DEFINE_INT8(CRASH_DETECT,0),

    // @Param: LIM_ROLL_CD
    // @DisplayName: Maximum Bank Angle
    // @Description: Maximum bank angle commanded in modes with stabilized limits. Increase this value for sharper turns, but decrease to prevent accelerated stalls.
    // @Units: cdeg
    // @Range: 0 9000
    // @Increment: 10
    // @User: Standard
    PARAM_DEFINE_INT16(LIM_ROLL_CD,    HEAD_MAX_CENTIDEGREE),

    // @Param: LIM_PITCH_MAX
    // @DisplayName: Maximum Pitch Angle
    // @Description: Maximum pitch up angle commanded in modes with stabilized limits.
    // @Units: cdeg
    // @Range: 0 9000
    // @Increment: 10
    // @User: Standard
    PARAM_DEFINE_INT16(LIM_PITCH_MAX,  PITCH_MAX_CENTIDEGREE),

    // @Param: LIM_PITCH_MIN
    // @DisplayName: Minimum Pitch Angle
    // @Description: Maximum pitch down angle commanded in modes with stabilized limits
    // @Units: cdeg
    // @Range: -9000 0
    // @Increment: 10
    // @User: Standard
    PARAM_DEFINE_INT16(LIM_PITCH_MIN,  PITCH_MIN_CENTIDEGREE),

    // @Param: AUTOTUNE_LEVEL
    // @DisplayName: Autotune level
    // @Description: Level of aggressiveness of pitch and roll PID gains. Lower values result in a 'softer' tune. Level 6 recommended for most planes. A value of 0 means to keep the current values of RMAX and TCONST for the controllers, tuning only the PID values
    // @Range: 0 10
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(AUTOTUNE_LEVEL,  6),

    // @Param: STALL_PREVENTION
    // @DisplayName: Enable stall prevention
    // @Description: Enables roll limits at low airspeed in roll limiting flight modes. Roll limits based on aerodynamic load factor in turns and scale on ARSPD_FBW_MIN that must be set correctly. Without airspeed sensor, uses synthetic airspeed from wind speed estimate that may both be inaccurate.
    // @Values: 0:Disabled,1:Enabled
    // @User: Standard
    PARAM_DEFINE_INT8(STALL_PREVENTION, 1),

    // @Param: WP_LOITER_RAD
    // @DisplayName: Waypoint Loiter Radius
    // @Description: Defines the distance from the waypoint center, the plane will maintain during a loiter. If you set this value to a negative number then the default loiter direction will be counter-clockwise instead of clockwise.
    // @Units: m
    // @Range: -32767 32767
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT16(WP_LOITER_RAD,  LOITER_RADIUS_DEFAULT),

    // @Param: TRIM_PITCH_CD
    // @DisplayName: Pitch angle offset
    // @Description: Offset applied to AHRS pitch used for in-flight pitch trimming. Correct ground leveling is better than changing this parameter.
    // @Units: cdeg
    // @Range: -4500 4500
    // @Increment: 10
    // @User: Advanced
    PARAM_DEFINE_INT16(TRIM_PITCH_CD,  0),

    // @Param: TKOFF_THR_MAX_T
    // @DisplayName: Takeoff throttle maximum time
    // @Description: This sets the time that maximum throttle will be forced during a fixed wing takeoff without an airspeed sensor. If an airspeed sensor is being used then the throttle is set to maximum until the takeoff airspeed is reached.
    // @Units: s
    // @Range: 0 10
    // @Increment: 0.5
    // @User: Standard
    PARAM_DEFINE_FLOAT(TKOFF_THR_MAX_T,  4),

    // @Param: FLTMODE_CH
    // @DisplayName: Flightmode channel
    // @Description: RC Channel to use for flight mode control
    // @Values: 0:Disabled,1:Channel 1,2:Channel 2,3:Channel 3,4:Channel 4,5:Channel 5,6:Channel 6,7:Channel 7,8:Channel 8,9:Channel 9,10:Channel 10,11:Channel 11,12:Channel 12,13:Channel 13,14:Channel 14,15:Channel 15,16:Channel 16
    // @User: Advanced
    PARAM_DEFINE_INT8(FLTMODE_CH,FLIGHT_MODE_CHANNEL),

    // @Param: FLTMODE1
    // @DisplayName: FlightMode1
    // @Description: Flight mode for switch position 1 (910 to 1230 and above 2049)
    // @Values: 0:Manual,1:CIRCLE,2:STABILIZE,3:TRAINING,4:ACRO,5:FBWA,6:FBWB,7:CRUISE,8:AUTOTUNE,10:Auto,11:RTL,12:Loiter,13:TAKEOFF,14:AVOID_ADSB,15:Guided,17:QSTABILIZE,18:QHOVER,19:QLOITER,20:QLAND,21:QRTL,22:QAUTOTUNE,23:QACRO,24:THERMAL,25:Loiter to QLand
    // @User: Standard
    PARAM_DEFINE_INT8(FLTMODE1,FLIGHT_MODE_1),

    // @Param: FLTMODE2
    // @CopyFieldsFrom: FLTMODE1
    // @DisplayName: FlightMode2
    // @Description: Flight mode for switch position 2 (1231 to 1360)
    PARAM_DEFINE_INT8(FLTMODE2,FLIGHT_MODE_2),

    // @Param: FLTMODE3
    // @CopyFieldsFrom: FLTMODE1
    // @DisplayName: FlightMode3
    // @Description: Flight mode for switch position 3 (1361 to 1490)
    PARAM_DEFINE_INT8(FLTMODE3,FLIGHT_MODE_3),

    // @Param: FLTMODE4
    // @CopyFieldsFrom: FLTMODE1
    // @DisplayName: FlightMode4
    // @Description: Flight mode for switch position 4 (1491 to 1620)
    PARAM_DEFINE_INT8(FLTMODE4,FLIGHT_MODE_4),

    // @Param: FLTMODE5
    // @CopyFieldsFrom: FLTMODE1
    // @DisplayName: FlightMode5
    // @Description: Flight mode for switch position 5 (1621 to 1749)
    PARAM_DEFINE_INT8(FLTMODE5,FLIGHT_MODE_5),

    // @Param: FLTMODE6
    // @CopyFieldsFrom: FLTMODE1
    // @DisplayName: FlightMode6
    // @Description: Flight mode for switch position 6 (1750 to 2049)
    PARAM_DEFINE_INT8(FLTMODE6,FLIGHT_MODE_6),

    // @Param: INITIAL_MODE
    // @DisplayName: Initial flight mode
    // @Description: This selects the mode to start in on boot. This is useful for when you want to start in AUTO mode on boot without a receiver.
    // @CopyValuesFrom: FLTMODE1
    // @User: Advanced
    PARAM_DEFINE_INT8(INITIAL_MODE,MN_MANUAL),

    // @Param: RNGFND_LANDING
    // @DisplayName: Enable rangefinder for landing
    // @Description: This enables the use of a rangefinder for automatic landing. The rangefinder will be used both on the landing approach and for final flare
    // @Values: 0:Disabled,1:Enabled
    // @User: Standard
    PARAM_DEFINE_INT8(RNGFND_LANDING,   0),

    // @Param: STICK_MIXING
    // @DisplayName: Stick Mixing
    // @Description: When enabled, this adds user stick input to the control surfaces in auto modes, allowing the user to have some degree of flight control without changing modes.  There are two types of stick mixing available. If you set STICK_MIXING to 1 then it will use "fly by wire" mixing, which controls the roll and pitch in the same way that the FBWA mode does. This is the safest option if you usually fly ArduPlane in FBWA or FBWB mode. If you set STICK_MIXING to 3 then it will apply to the yaw while in quadplane modes only, such as while doing an automatic VTOL takeoff or landing.
    // @Values: 0:Disabled,1:FBWMixing,3:VTOL Yaw only
    // @User: Advanced
    PARAM_DEFINE_INT8(STICK_MIXING,   SM_FBW),

    // @Param: THR_SUPP_MAN
    // @DisplayName: Throttle suppress manual passthru
    // @Description: When throttle is suppressed in auto mode it is normally forced to zero. If you enable this option, then while suppressed it will be manual throttle. This is useful on petrol engines to hold the idle throttle manually while waiting for takeoff
    // @Values: 0:Disabled,1:Enabled
    // @User: Advanced
    PARAM_DEFINE_INT8(THR_SUPP_MAN,   0),

    // @Param: THR_PASS_STAB
    // @DisplayName: Throttle passthru in stabilize
    // @Description: If this is set then when in STABILIZE, FBWA or ACRO modes the throttle is a direct passthru from the transmitter. This means the THR_MIN and THR_MAX settings are not used in these modes. This is useful for petrol engines where you setup a throttle cut switch that suppresses the throttle below the normal minimum.
    // @Values: 0:Disabled,1:Enabled
    // @User: Advanced
    PARAM_DEFINE_INT8(THR_PASS_STAB,   0),

    // @Param: THR_FAILSAFE
    // @DisplayName: Throttle and RC Failsafe Enable
    // @Description: 0 disables the failsafe. 1 enables failsafe on loss of RC input. This is detected either by throttle values below THR_FS_VALUE, loss of receiver valid pulses/data, or by the FS bit in receivers that provide it, like SBUS. A programmable failsafe action will occur and RC inputs, if present, will be ignored. A value of 2 means that the RC inputs won't be used when RC failsafe is detected by any of the above methods, but it won't trigger an RC failsafe action.
    // @Values: 0:Disabled,1:Enabled,2:EnabledNoFailsafe
    // @User: Standard
    PARAM_DEFINE_INT8(THR_FAILSAFE,   TFS_Enabled),


    // @Param: THR_FS_VALUE
    // @DisplayName: Throttle Failsafe Value
    // @Description: The PWM level on the throttle input channel below which throttle failsafe triggers. Note that this should be well below the normal minimum for your throttle channel.
    // @Range: 925 2200
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT16(THR_FS_VALUE,   950),

    // @Param: THROTTLE_NUDGE
    // @DisplayName: Throttle nudge enable
    // @Description: When enabled, this uses the throttle input in auto-throttle modes to 'nudge' the throttle or airspeed to higher or lower values. When you have an airspeed sensor the nudge affects the target airspeed, so that throttle inputs above 50% will increase the target airspeed from TRIM_ARSPD_CM up to a maximum of ARSPD_FBW_MAX. When no airspeed sensor is enabled the throttle nudge will push up the target throttle for throttle inputs above 50%.
    // @Values: 0:Disabled,1:Enabled
    // @User: Standard
    PARAM_DEFINE_INT8(THROTTLE_NUDGE,  1),

    // @Param: USE_REV_THRUST
    // @DisplayName: Bitmask for when to allow negative reverse thrust
    // @Description: This controls when to use reverse thrust. If set to zero then reverse thrust is never used. If set to a non-zero value then the bits correspond to flight stages where reverse thrust may be used. The most commonly used value for USE_REV_THRUST is 2, which means AUTO_LAND only. That enables reverse thrust in the landing stage of AUTO mode. Another common choice is 1, which means to use reverse thrust in all auto flight stages. Reverse thrust is always used in MANUAL mode if enabled with THR_MIN < 0. In non-autothrottle controlled modes, if reverse thrust is not used, then THR_MIN is effectively set to 0 for that mode.
    // @Values: 0:MANUAL ONLY,1:AutoAlways,2:AutoLanding
    // @Bitmask: 0:AUTO_ALWAYS,1:AUTO_LAND,2:AUTO_LOITER_TO_ALT,3:AUTO_LOITER_ALL,4:AUTO_WAYPOINTS,5:LOITER,6:RTL,7:CIRCLE,8:CRUISE,9:FBWB,10:GUIDED,11:AUTO_LANDING_PATTERN,12:FBWA,13:ACRO,14:STABILIZE,15:THERMAL
    // @User: Advanced
    PARAM_DEFINE_INT32(USE_REV_THRUST,  USE_REVERSE_THRUST_AUTO_LAND_APPROACH),

    // @Param: FS_SHORT_ACTN
    // @DisplayName: Short failsafe action
    // @Description: The action to take on a short (FS_SHORT_TIMEOUT) failsafe event. A short failsafe event can be triggered either by loss of RC control (see THR_FS_VALUE) or by loss of GCS control (see FS_GCS_ENABL). If in CIRCLE or RTL mode this parameter is ignored. A short failsafe event in stabilization and manual modes will cause a change to CIRCLE mode if FS_SHORT_ACTN is 0 or 1, a change to FBWA mode with zero throttle if FS_SHORT_ACTN is 2, and a change to FBWB mode if FS_SHORT_ACTN is 4. In all other modes (AUTO, GUIDED and LOITER) a short failsafe event will cause no mode change if FS_SHORT_ACTN is set to 0, will cause a change to CIRCLE mode if set to 1, will change to FBWA mode with zero throttle if set to 2, or will change to FBWB if set to 4. Please see the documentation for FS_LONG_ACTN for the behaviour after FS_LONG_TIMEOUT seconds of failsafe.
    // @Values: 0:CIRCLE/no change(if already in AUTO|GUIDED|LOITER),1:CIRCLE,2:FBWA at zero throttle,3:Disable,4:FBWB
    // @User: Standard
    PARAM_DEFINE_INT8(FS_SHORT_ACTN,  FS_ACTION_SHORT_BESTGUESS),

    // @Param: FS_LONG_ACTN
    // @DisplayName: Long failsafe action
    // @Description: The action to take on a long (FS_LONG_TIMEOUT seconds) failsafe event. If the aircraft was in a stabilization or manual mode when failsafe started and a long failsafe occurs then it will change to RTL mode if FS_LONG_ACTN is 0 or 1, and will change to FBWA if FS_LONG_ACTN is set to 2. If the aircraft was in an auto mode (such as AUTO or GUIDED) when the failsafe started then it will continue in the auto mode if FS_LONG_ACTN is set to 0, will change to RTL mode if FS_LONG_ACTN is set to 1 and will change to FBWA mode if FS_LONG_ACTN is set to 2. If FS_LONG_ACTION is set to 3, the parachute will be deployed (make sure the chute is configured and enabled). 
    // @Values: 0:Continue,1:ReturnToLaunch,2:Glide,3:Deploy Parachute
    // @User: Standard
    PARAM_DEFINE_INT8(FS_LONG_ACTN,   FS_ACTION_LONG_CONTINUE),

    // @Param: FS_SHORT_TIMEOUT
    // @DisplayName: Short failsafe timeout
    // @Description: The time in seconds that a failsafe condition has to persist before a short failsafe event will occur. This defaults to 1.5 seconds
    // @Units: s
    // @Range: 1 100
    // @Increment: 0.5
    // @User: Standard
    PARAM_DEFINE_FLOAT(FS_SHORT_TIMEOUT, 1.5f),

    // @Param: FS_LONG_TIMEOUT
    // @DisplayName: Long failsafe timeout
    // @Description: The time in seconds that a failsafe condition has to persist before a long failsafe event will occur. This defaults to 5 seconds.
    // @Units: s
    // @Range: 1 300
    // @Increment: 0.5
    // @User: Standard
    PARAM_DEFINE_FLOAT(FS_LONG_TIMEOUT, 5),

    // @Param: FS_GCS_ENABL
    // @DisplayName: GCS failsafe enable
    // @Description: Enable ground control station telemetry failsafe. Failsafe will trigger after FS_LONG_TIMEOUT seconds of no MAVLink heartbeat messages. There are three possible enabled settings. Setting FS_GCS_ENABL to 1 means that GCS failsafe will be triggered when the aircraft has not received a MAVLink HEARTBEAT message. Setting FS_GCS_ENABL to 2 means that GCS failsafe will be triggered on either a loss of HEARTBEAT messages, or a RADIO_STATUS message from a MAVLink enabled 3DR radio indicating that the ground station is not receiving status updates from the aircraft, which is indicated by the RADIO_STATUS.remrssi field being zero (this may happen if you have a one way link due to asymmetric noise on the ground station and aircraft radios).Setting FS_GCS_ENABL to 3 means that GCS failsafe will be triggered by Heartbeat(like option one), but only in AUTO mode. WARNING: Enabling this option opens up the possibility of your plane going into failsafe mode and running the motor on the ground it it loses contact with your ground station. If this option is enabled on an electric plane then you should enable ARMING_REQUIRED.
    // @Values: 0:Disabled,1:Heartbeat,2:HeartbeatAndREMRSSI,3:HeartbeatAndAUTO
    // @User: Standard
    PARAM_DEFINE_INT8(FS_GCS_ENABL, GCS_FAILSAFE_OFF),

    // @Param: MAN_EXPO_ROLL
    // @DisplayName: Manual control expo for roll
    // @Description: Percentage exponential for roll input in MANUAL, ACRO and TRAINING modes
    // @Range: 0 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(MAN_EXPO_ROLL, 0),

    // @Param: MAN_EXPO_PITCH
    // @DisplayName: Manual input expo for pitch
    // @Description: Percentage exponential for pitch input in MANUAL, ACRO and TRAINING modes
    // @Range: 0 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(MAN_EXPO_PITCH, 0),

    // @Param: MAN_EXPO_RUDDER
    // @DisplayName: Manual input expo for rudder
    // @Description: Percentage exponential for rudder input in MANUAL, ACRO and TRAINING modes
    // @Range: 0 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(MAN_EXPO_RUDDER, 0),

    // @Param: RUDDER_ONLY
    // @DisplayName: Rudder only aircraft
    // @Description: Enable rudder only mode. The rudder will control attitude in attitude controlled modes (such as FBWA). You should setup your transmitter to send roll stick inputs to the RCMAP_YAW channel (normally channel 4). The rudder servo should be attached to the RCMAP_YAW channel as well. Note that automatic ground steering will be disabled for rudder only aircraft. You should also set KFF_RDDRMIX to 1.0. You will also need to setup the YAW2SRV_DAMP yaw damping appropriately for your aircraft. A value of 0.5 for YAW2SRV_DAMP is a good starting point.
    // @Values: 0:Disabled,1:Enabled
    // @User: Standard
    PARAM_DEFINE_INT8(RUDDER_ONLY,  0),

    // @Param: HOME_RESET_ALT
    // @DisplayName: Home reset altitude threshold
    // @Description: When the aircraft is within this altitude of the home waypoint, while disarmed it will automatically update the home position. Set to 0 to continously reset it.
    // @Values: -1:Never reset,0:Always reset
    // @Range: -1 127
    // @Units: m
    // @User: Advanced
    PARAM_DEFINE_INT8(HOME_RESET_ALT, 0),

    // @Param: FLIGHT_OPTIONS
    // @DisplayName: Flight mode options
    // @Description: Flight mode specific options
    // @Bitmask: 0: Rudder mixing in direct flight modes only (Manual/Stabilize/Acro)
    // @Bitmask: 1: Use centered throttle in Cruise or FBWB to indicate trim airspeed
    // @Bitmask: 2: Disable attitude check for takeoff arming
    // @Bitmask: 3: Force target airspeed to trim airspeed in Cruise or FBWB
    // @Bitmask: 4: Climb to ALT_HOLD_RTL before turning for RTL
    // @Bitmask: 5: Enable yaw damper in acro mode
    // @Bitmask: 6: Supress speed scaling during auto takeoffs to be 1 or less to prevent oscillations without airspeed sensor.
    // @Bitmask: 7: EnableDefaultAirspeed for takeoff
    // @Bitmask: 8: Remove the TRIM_PITCH_CD on the GCS horizon
    // @Bitmask: 9: Remove the TRIM_PITCH_CD on the OSD horizon
    // @Bitmask: 10: Adjust mid-throttle to be TRIM_THROTTLE in non-auto throttle modes except MANUAL
    // @Bitmask: 11: Disable suppression of fixed wing rate gains in ground mode
    // @Bitmask: 12: Enable FBWB style loiter altitude control
    // @Bitmask: 13: Indicate takeoff waiting for neutral rudder with flight control surfaces
    // @User: Advanced
    PARAM_DEFINE_INT32(FLIGHT_OPTIONS, 0),

    // @Param: RTL_AUTOLAND
    // @DisplayName: RTL auto land
    // @Description: Automatically begin landing sequence after arriving at RTL location. This requires the addition of a DO_LAND_START mission item, which acts as a marker for the start of a landing sequence. The closest landing sequence will be chosen to the current location. If this is set to 0 and there is a DO_LAND_START mission item then you will get an arming check failure. You can set to a value of 3 to avoid the arming check failure and use the DO_LAND_START for go-around without it changing RTL behaviour. For a value of 1 a rally point will be used instead of HOME if in range (see rally point documentation).
    // @Values: 0:Disable,1:Fly HOME then land,2:Go directly to landing sequence, 3:OnlyForGoAround
    // @User: Standard
    PARAM_DEFINE_INT8(RTL_AUTOLAND,    RAL_RTL_DISABLE),

    // @Param: RUDD_DT_GAIN
    // @DisplayName: rudder differential thrust gain
    // @Description: gain control from rudder to differential thrust
    // @Range: 0 100
    // @Units: %
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(RUDD_DT_GAIN, 10),

    // @Param: TKOFF_THR_MINSPD
    // @DisplayName: Takeoff throttle min speed
    // @Description: Minimum GPS ground speed in m/s used by the speed check that un-suppresses throttle in auto-takeoff. This can be be used for catapult launches where you want the motor to engage only after the plane leaves the catapult, but it is preferable to use the TKOFF_THR_MINACC and TKOFF_THR_DELAY parameters for catapult launches due to the errors associated with GPS measurements. For hand launches with a pusher prop it is strongly advised that this parameter be set to a value no less than 4 m/s to provide additional protection against premature motor start. Note that the GPS velocity will lag the real velocity by about 0.5 seconds. The ground speed check is delayed by the TKOFF_THR_DELAY parameter.
    // @Units: m/s
    // @Range: 0 30
    // @Increment: 0.1
    // @User: Standard
    PARAM_DEFINE_FLOAT(TKOFF_THR_MINSPD,  0),

    // @Param: TKOFF_THR_MINACC
    // @DisplayName: Takeoff throttle min acceleration
    // @Description: Minimum forward acceleration in m/s/s before arming the ground speed check in auto-takeoff. This is meant to be used for hand launches. Setting this value to 0 disables the acceleration test which means the ground speed check will always be armed which could allow GPS velocity jumps to start the engine. For hand launches and bungee launches this should be set to around 15. Also see TKOFF_ACCEL_CNT paramter for control of full "shake to arm".
    // @Units: m/s/s
    // @Range: 0 30
    // @Increment: 0.1
    // @User: Standard
    PARAM_DEFINE_FLOAT(TKOFF_THR_MINACC,  0),

    // @Param: TKOFF_THR_DELAY
    // @DisplayName: Takeoff throttle delay
    // @Description: This parameter sets the time delay (in 1/10ths of a second) that the ground speed check is delayed after the forward acceleration check controlled by TKOFF_THR_MINACC has passed. For hand launches with pusher propellers it is essential that this is set to a value of no less than 2 (0.2 seconds) to ensure that the aircraft is safely clear of the throwers arm before the motor can start. For bungee launches a larger value can be used (such as 30) to give time for the bungee to release from the aircraft before the motor is started.
    // @Units: ds
    // @Range: 0 127
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(TKOFF_THR_DELAY,  2),

    // @Param: TKOFF_TDRAG_ELEV
    // @DisplayName: Takeoff tail dragger elevator
    // @Description: This parameter sets the amount of elevator to apply during the initial stage of a takeoff. It is used to hold the tail wheel of a taildragger on the ground during the initial takeoff stage to give maximum steering. This option should be combined with the TKOFF_TDRAG_SPD1 option and the GROUND_STEER_ALT option along with tuning of the ground steering controller. A value of zero means to bypass the initial "tail hold" stage of takeoff. Set to zero for hand and catapult launch. For tail-draggers you should normally set this to 100, meaning full up elevator during the initial stage of takeoff. For most tricycle undercarriage aircraft a value of zero will work well, but for some tricycle aircraft a small negative value (say around -20 to -30) will apply down elevator which will hold the nose wheel firmly on the ground during initial acceleration. Only use a negative value if you find that the nosewheel doesn't grip well during takeoff. Too much down elevator on a tricycle undercarriage may cause instability in steering as the plane pivots around the nosewheel. Add down elevator 10 percent at a time.
    // @Units: %
    // @Range: -100 100
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(TKOFF_TDRAG_ELEV,  0),

    // @Param: TKOFF_TDRAG_SPD1
    // @DisplayName: Takeoff tail dragger speed1
    // @Description: This parameter sets the airspeed at which to stop holding the tail down and transition to rudder control of steering on the ground. When TKOFF_TDRAG_SPD1 is reached the pitch of the aircraft will be held level until TKOFF_ROTATE_SPD is reached, at which point the takeoff pitch specified in the mission will be used to "rotate" the pitch for takeoff climb. Set TKOFF_TDRAG_SPD1 to zero to go straight to rotation. This should be set to zero for hand launch and catapult launch. It should also be set to zero for tricycle undercarriages unless you are using the method above to genetly hold the nose wheel down. For tail dragger aircraft it should be set just below the stall speed.
    // @Units: m/s
    // @Range: 0 30
    // @Increment: 0.1
    // @User: Standard
    PARAM_DEFINE_FLOAT(TKOFF_TDRAG_SPD1,  0),

    // @Param: TKOFF_ROTATE_SPD
    // @DisplayName: Takeoff rotate speed
    // @Description: This parameter sets the airspeed at which the aircraft will "rotate", setting climb pitch specified in the mission. If TKOFF_ROTATE_SPD is zero then the climb pitch will be used as soon as takeoff is started. For hand launch and catapult launches a TKOFF_ROTATE_SPD of zero should be set. For all ground launches TKOFF_ROTATE_SPD should be set above the stall speed, usually by about 10 to 30 percent. During the run, use TKOFF_GND_PITCH to keep the aircraft on the runway while below this airspeed.
    // @Units: m/s
    // @Range: 0 30
    // @Increment: 0.1
    // @User: Standard
    PARAM_DEFINE_FLOAT(TKOFF_ROTATE_SPD,  0),

    // @Param: TKOFF_THR_SLEW
    // @DisplayName: Takeoff throttle slew rate
    // @Description: This parameter sets the slew rate for the throttle during auto takeoff. When this is zero the THR_SLEWRATE parameter is used during takeoff. For rolling takeoffs it can be a good idea to set a lower slewrate for takeoff to give a slower acceleration which can improve ground steering control. The value is a percentage throttle change per second, so a value of 20 means to advance the throttle over 5 seconds on takeoff. Values below 20 are not recommended as they may cause the plane to try to climb out with too little throttle. A value of -1 means no limit on slew rate in takeoff.
    // @Units: %/s
    // @Range: -1 127
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT8(TKOFF_THR_SLEW,  0),

    // @Param: TKOFF_PLIM_SEC
    // @DisplayName: Takeoff pitch limit reduction
    // @Description: This parameter reduces the pitch minimum limit of an auto-takeoff just a few seconds before it reaches the target altitude. This reduces overshoot by allowing the flight controller to start leveling off a few seconds before reaching the target height. When set to zero, the mission pitch min is enforced all the way to and through the target altitude, otherwise the pitch min slowly reduces to zero in the final segment. This is the pitch_min, not the demand. The flight controller should still be commanding to gain altitude to finish the takeoff but with this param it is not forcing it higher than it wants to be.
    // @Units: s
    // @Range: 0 10
    // @Increment: 0.5
    // @User: Advanced
    PARAM_DEFINE_FLOAT(TKOFF_PLIM_SEC,  2),

    // @Param: TKOFF_FLAP_PCNT
    // @DisplayName: Takeoff flap percentage
    // @Description: The amount of flaps (as a percentage) to apply in automatic takeoff
    // @Range: 0 100
    // @Units: %
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(TKOFF_FLAP_PCNT, 0),

    // @Param: MIXING_GAIN
    // @DisplayName: Mixing Gain
    // @Description: The gain for the Vtail and elevon output mixers. The default is 0.5, which ensures that the mixer doesn't saturate, allowing both input channels to go to extremes while retaining control over the output. Hardware mixers often have a 1.0 gain, which gives more servo throw, but can saturate. If you don't have enough throw on your servos with VTAIL_OUTPUT or ELEVON_OUTPUT enabled then you can raise the gain using MIXING_GAIN. The mixer allows outputs in the range 900 to 2100 microseconds.
    // @Range: 0.5 1.2
    // @User: Standard
    PARAM_DEFINE_FLOAT(MIXING_GAIN,    0.5f),

    // @Param: MIXING_OFFSET
    // @DisplayName: Mixing Offset
    // @Description: The offset for the Vtail and elevon output mixers, as a percentage. This can be used in combination with MIXING_GAIN to configure how the control surfaces respond to input. The response to aileron or elevator input can be increased by setting this parameter to a positive or negative value. A common usage is to enter a positive value to increase the aileron response of the elevons of a flying wing. The default value of zero will leave the aileron-input response equal to the elevator-input response.
    // @Units: d%
    // @Range: -1000 1000
    // @User: Standard
    PARAM_DEFINE_FLOAT(MIXING_OFFSET,  0),

    // @Param: DSPOILER_CROW_W1
    // @DisplayName: Differential spoiler crow flaps outer weight
    // @Description: This is amount of deflection applied to the two outer surfaces for differential spoilers for flaps to give crow flaps. It is a number from 0 to 100. At zero no crow flaps are applied. A recommended starting value is 25.
    // @Range: 0 100
    // @Units: %
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(DSPOILER_CROW_W1, 0),

    // @Param: DSPOILER_CROW_W2
    // @DisplayName: Differential spoiler crow flaps inner weight
    // @Description: This is amount of deflection applied to the two inner surfaces for differential spoilers for flaps to give crow flaps. It is a number from 0 to 100. At zero no crow flaps are applied. A recommended starting value is 45.
    // @Range: 0 100
    // @Units: %
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(DSPOILER_CROW_W2, 0),

    // @Param: DSPOILER_OPTS
    // @DisplayName: Differential spoiler and crow flaps options
    // @Description: Differential spoiler and crow flaps options
    // @Values: 0: none, 1: D spoilers have pitch input, 2: use both control surfaces on each wing for roll, 4: Progressive crow flaps only first (0-50% flap in) then crow flaps (50 - 100% flap in)
    // @Bitmask: 0:pitch control, 1:full span, 2:Progressive crow
    // @User: Advanced
    PARAM_DEFINE_INT8(DSPOILER_OPTS, 3),

    // @Param: DSPOILER_AILMTCH
    // @DisplayName: Differential spoiler aileron matching
    // @Description: This scales down the inner flaps so less than full downwards range can be used for differential spoiler and full span ailerons, 100 is use full range, upwards travel is unaffected
    // @Range: 0 100
    // @Units: %
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(DSPOILER_AILMTCH, 100),

    // @Param: DSPOILR_RUD_RATE
    // @DisplayName: Differential spoilers rudder rate
    // @Description: Sets the amount of deflection that the rudder output will apply to the differential spoilers, as a percentage. The default value of 100 results in full rudder applying full deflection. A value of 0 will result in the differential spoilers exactly following the elevons (no rudder effect).
    // @Units: %
    // @Range: -100 100
    // @User: Standard
    PARAM_DEFINE_INT16(DSPOILR_RUD_RATE,  DSPOILR_RUD_RATE_DEFAULT),

    // @Param: MANUAL_RCMASK
    // @DisplayName: Manual R/C pass-through mask
    // @Description: Mask of R/C channels to pass directly to corresponding output channel when in MANUAL mode. When in any mode except MANUAL the channels selected with this option behave normally. This parameter is designed to allow for complex mixing strategies to be used for MANUAL flight using transmitter based mixing. Note that when this option is used you need to be very careful with pre-flight checks to ensure that the output is correct both in MANUAL and non-MANUAL modes.
    // @Bitmask: 0:Chan1,1:Chan2,2:Chan3,3:Chan4,4:Chan5,5:Chan6,6:Chan7,7:Chan8,8:Chan9,9:Chan10,10:Chan11,11:Chan12,12:Chan13,13:Chan14,14:Chan15,15:Chan16
    // @User: Advanced
    PARAM_DEFINE_INT32(MANUAL_RCMASK, 0),

    // @Param: FWD_BAT_VOLT_MAX
    // @DisplayName: Forward throttle battery voltage compensation maximum voltage
    // @Description: Forward throttle battery voltage compensation maximum voltage (voltage above this will have no additional scaling effect on thrust). Recommend 4.2 * cell count, 0 = Disabled. Recommend THR_MAX is set to no more than 100 x FWD_BAT_VOLT_MIN / FWD_BAT_VOLT_MAX, THR_MIN is set to no less than -100 x FWD_BAT_VOLT_MIN / FWD_BAT_VOLT_MAX and climb descent rate limits are set accordingly.
    // @Range: 6 35
    // @Units: V
    // @Increment: 0.1
    // @User: Advanced
    PARAM_DEFINE_FLOAT(FWD_BAT_VOLT_MAX, 0.0f),

    // @Param: FWD_BAT_VOLT_MIN
    // @DisplayName: Forward throttle battery voltage compensation minimum voltage
    // @Description: Forward throttle battery voltage compensation minimum voltage (voltage below this will have no additional scaling effect on thrust).  Recommend 3.5 * cell count, 0 = Disabled. Recommend THR_MAX is set to no more than 100 x FWD_BAT_VOLT_MIN / FWD_BAT_VOLT_MAX, THR_MIN is set to no less than -100 x FWD_BAT_VOLT_MIN / FWD_BAT_VOLT_MAX and climb descent rate limits are set accordingly.
    // @Range: 6 35
    // @Units: V
    // @Increment: 0.1
    // @User: Advanced
    PARAM_DEFINE_FLOAT(FWD_BAT_VOLT_MIN, 0.0f),

    // @Param: FWD_BAT_IDX
    // @DisplayName: Forward throttle battery compensation index
    // @Description: Which battery monitor should be used for doing compensation for the forward throttle
    // @Values: 0:First battery, 1:Second battery
    // @User: Advanced
    PARAM_DEFINE_INT8(FWD_BAT_IDX, 0),

    // @Param: ALT_OFFSET
    // @DisplayName: Altitude offset
    // @Description: This is added to the target altitude in automatic flight. It can be used to add a global altitude offset to a mission
    // @Units: m
    // @Range: -32767 32767
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT16(ALT_OFFSET,  0),

    // @Param: ACRO_ROLL_RATE
    // @DisplayName: ACRO mode roll rate
    // @Description: The maximum roll rate at full stick deflection in ACRO mode
    // @Units: deg/s
    // @Range: 10 500
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT16(ACRO_ROLL_RATE,   180),

    // @Param: ACRO_PITCH_RATE
    // @DisplayName: ACRO mode pitch rate
    // @Description: The maximum pitch rate at full stick deflection in ACRO mode
    // @Units: deg/s
    // @Range: 10 500
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT16(ACRO_PITCH_RATE,  180),

    // @Param: ACRO_YAW_RATE
    // @DisplayName: ACRO mode yaw rate
    // @Description: The maximum yaw rate at full stick deflection in ACRO mode. If this is zero then rudder is directly controlled by rudder stick input. This option is only available if you also set YAW_RATE_ENABLE to 1.
    // @Units: deg/s
    // @Range: 0 500
    // @Increment: 1
    // @User: Standard
    PARAM_DEFINE_INT16(ACRO_YAW_RATE,   0),
    
    // @Param: ACRO_LOCKING
    // @DisplayName: ACRO mode attitude locking
    // @Description: Enable attitude locking when sticks are released. If set to 2 then quaternion based locking is used if the yaw rate controller is enabled. Quaternion based locking will hold any attitude
    // @Values: 0:Disabled,1:Enabled,2:Quaternion
    // @User: Standard
    PARAM_DEFINE_INT8(ACRO_LOCKING,     0),

    // @Param: FLAP_1_PERCNT
    // @DisplayName: Flap 1 percentage
    // @Description: The percentage change in flap position when FLAP_1_SPEED is reached. Use zero to disable flaps
    // @Range: 0 100
    // @Increment: 1
    // @Units: %
    // @User: Advanced
    PARAM_DEFINE_INT8(FLAP_1_PERCNT,  FLAP_1_PERCENT),

    // @Param: FLAP_1_SPEED
    // @DisplayName: Flap 1 speed
    // @Description: The speed in meters per second at which to engage FLAP_1_PERCENT of flaps. Note that FLAP_1_SPEED should be greater than or equal to FLAP_2_SPEED
    // @Range: 0 100
    // @Increment: 1
    // @Units: m/s
    // @User: Advanced
    PARAM_DEFINE_INT8(FLAP_1_SPEED,   FLAP_1_SPEED),

    // @Param: FLAP_2_PERCNT
    // @DisplayName: Flap 2 percentage
    // @Description: The percentage change in flap position when FLAP_2_SPEED is reached. Use zero to disable flaps
    // @Range: 0 100
    // @Units: %
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(FLAP_2_PERCNT,  FLAP_2_PERCENT),

    // @Param: FLAP_2_SPEED
    // @DisplayName: Flap 2 speed
    // @Description: The speed in meters per second at which to engage FLAP_2_PERCENT of flaps. Note that FLAP_1_SPEED should be greater than or equal to FLAP_2_SPEED
    // @Range: 0 100
    // @Units: m/s
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(FLAP_2_SPEED,   FLAP_2_SPEED),

    // @Param: FLAP_SLEWRATE
    // @DisplayName: Flap slew rate
    // @Description: maximum percentage change in flap output per second. A setting of 25 means to not change the flap by more than 25% of the full flap range in one second. A value of 0 means no rate limiting.
    // @Units: %/s
    // @Range: 0 100
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(FLAP_SLEWRATE,   75),

    // @Param: CRASH_ACC_THRESH
    // @DisplayName: Crash Deceleration Threshold
    // @Description: X-Axis deceleration threshold to notify the crash detector that there was a possible impact which helps disarm the motor quickly after a crash. This value should be much higher than normal negative x-axis forces during normal flight, check flight log files to determine the average IMU.x values for your aircraft and motor type. Higher value means less sensative (triggers on higher impact). For electric planes that don't vibrate much during fight a value of 25 is good (that's about 2.5G). For petrol/nitro planes you'll want a higher value. Set to 0 to disable the collision detector.
    // @Units: m/s/s
    // @Range: 10 127
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT8(CRASH_ACC_THRESH,   0),

    // @Param: KFF_RDDRMIX
    // @DisplayName: Rudder Mix
    // @Description: Amount of rudder to add during aileron movement. Increase if nose initially yaws away from roll. Reduces adverse yaw.
    // @Range: 0 1
    // @Increment: 0.01
    // @User: Standard
    PARAM_DEFINE_FLOAT(KFF_RDDRMIX,    RUDDER_MIX),

    // @Param: KFF_THR2PTCH
    // @DisplayName: Throttle to Pitch Mix
    // @Description: Pitch up to add in proportion to throttle. 100% throttle will add this number of degrees to the pitch target.
    // @Range: -5 5
    // @Increment: 0.01
    // @User: Advanced
    PARAM_DEFINE_FLOAT(KFF_THR2PTCH,   0),

    // @Param: GROUND_STEER_ALT
    // @DisplayName: Ground steer altitude
    // @Description: Altitude at which to use the ground steering controller on the rudder. If non-zero then the STEER2SRV controller will be used to control the rudder for altitudes within this limit of the home altitude.
    // @Units: m
    // @Range: -100 100
    // @Increment: 0.1
    // @User: Standard
    PARAM_DEFINE_FLOAT(GROUND_STEER_ALT,   0),

    // @Param: GROUND_STEER_DPS
    // @DisplayName: Ground steer rate
    // @Description: Ground steering rate in degrees per second for full rudder stick deflection
    // @Units: deg/s
    // @Range: 10 360
    // @Increment: 1
    // @User: Advanced
    PARAM_DEFINE_INT16(GROUND_STEER_DPS,  90),

    // @Param: STAB_PITCH_DOWN
    // @DisplayName: Low throttle pitch down trim 
    // @Description: Degrees of down pitch added when throttle is below TRIM_THROTTLE in FBWA and AUTOTUNE modes. Scales linearly so full value is added when THR_MIN is reached. Helps to keep airspeed higher in glides or landing approaches and prevents accidental stalls. 2 degrees recommended for most planes.
    // @Range: 0 15
    // @Increment: 0.1
    // @Units: deg
    // @User: Advanced
    PARAM_DEFINE_FLOAT(STAB_PITCH_DOWN,   2.0f),

    // @Param: LOG_BITMASK
    // @DisplayName: Log bitmask
    // @Description: Bitmap of what on-board log types to enable. This value is made up of the sum of each of the log types you want to be saved. It is usually best just to enable all basic log types by setting this to 65535.
    // @Bitmask: 0:Fast Attitude,1:Medium Attitude,2:GPS,3:Performance,4:Control Tuning,5:Navigation Tuning,7:IMU,8:Mission Commands,9:Battery Monitor,10:Compass,11:TECS,12:Camera,13:RC Input-Output,14:Rangefinder,19:Raw IMU,20:Fullrate Attitude,21:Video Stabilization
    // @User: Advanced
    PARAM_DEFINE_INT32(LOG_BITMASK,    DEFAULT_LOG_BITMASK),
};
PARAM_GROUP_DEFINE(VEHICLE, var_info);
/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/
/**
  * @brief       
  * @param[in]     
  * @param[out]  
  * @retval      
  * @note        
  */
void fms_assign_param()
{
    param_link_variable(PARAM_ID(VEHICLE, FORMAT_VERSION), &fms.g.format_version);

    param_link_variable(PARAM_ID(VEHICLE, THR_MIN), &fms.aparm.throttle_min);
    param_link_variable(PARAM_ID(VEHICLE, THR_MAX), &fms.aparm.throttle_max);
    param_link_variable(PARAM_ID(VEHICLE, THR_SLEWRATE), &fms.aparm.throttle_slewrate);
    param_link_variable(PARAM_ID(VEHICLE, TRIM_THROTTLE), &fms.aparm.throttle_cruise);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_THR_MAX), &fms.aparm.takeoff_throttle_max);
    param_link_variable(PARAM_ID(VEHICLE, ARSPD_FBW_MIN), &fms.aparm.airspeed_min);
    param_link_variable(PARAM_ID(VEHICLE, ARSPD_FBW_MAX), &fms.aparm.airspeed_max);
    param_link_variable(PARAM_ID(VEHICLE, TRIM_ARSPD_CM), &fms.aparm.airspeed_cruise_cm);
    param_link_variable(PARAM_ID(VEHICLE, MIN_GNDSPD_CM), &fms.aparm.min_gndspeed_cm);
    param_link_variable(PARAM_ID(VEHICLE, CRASH_DETECT), &fms.aparm.crash_detection_enable);
    param_link_variable(PARAM_ID(VEHICLE, LIM_ROLL_CD), &fms.aparm.roll_limit_cd);
    param_link_variable(PARAM_ID(VEHICLE, LIM_PITCH_MAX), &fms.aparm.pitch_limit_max_cd);
    param_link_variable(PARAM_ID(VEHICLE, LIM_PITCH_MIN), &fms.aparm.pitch_limit_min_cd);
    param_link_variable(PARAM_ID(VEHICLE, AUTOTUNE_LEVEL), &fms.aparm.autotune_level);
    param_link_variable(PARAM_ID(VEHICLE, STALL_PREVENTION), &fms.aparm.stall_prevention);
    param_link_variable(PARAM_ID(VEHICLE, WP_LOITER_RAD), &fms.aparm.loiter_radius);
    param_link_variable(PARAM_ID(VEHICLE, TRIM_PITCH_CD), &fms.aparm.pitch_trim_cd);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_THR_MAX_T), &fms.aparm.takeoff_throttle_max_t);

    param_link_variable(PARAM_ID(VEHICLE, FLTMODE_CH), &fms.g.flight_mode_channel);
    param_link_variable(PARAM_ID(VEHICLE, FLTMODE1), &fms.g.flight_modes[0]);
    param_link_variable(PARAM_ID(VEHICLE, FLTMODE2), &fms.g.flight_modes[1]);
    param_link_variable(PARAM_ID(VEHICLE, FLTMODE3), &fms.g.flight_modes[2]);
    param_link_variable(PARAM_ID(VEHICLE, FLTMODE4), &fms.g.flight_modes[3]);
    param_link_variable(PARAM_ID(VEHICLE, FLTMODE5), &fms.g.flight_modes[4]);
    param_link_variable(PARAM_ID(VEHICLE, FLTMODE6), &fms.g.flight_modes[5]);
    param_link_variable(PARAM_ID(VEHICLE, INITIAL_MODE), &fms.g.initial_mode);

    param_link_variable(PARAM_ID(VEHICLE, RNGFND_LANDING), &fms.g.rangefinder_landing);
    param_link_variable(PARAM_ID(VEHICLE, STICK_MIXING), &fms.g.stick_mixing);

    param_link_variable(PARAM_ID(VEHICLE, THR_SUPP_MAN),   &fms.g.throttle_suppress_manual);
    param_link_variable(PARAM_ID(VEHICLE, THR_PASS_STAB),  &fms.g.throttle_passthru_stabilize);
    param_link_variable(PARAM_ID(VEHICLE, THR_FAILSAFE),   &fms.g.throttle_fs_enabled);
    param_link_variable(PARAM_ID(VEHICLE, THR_FS_VALUE),   &fms.g.throttle_fs_value);
    param_link_variable(PARAM_ID(VEHICLE, THROTTLE_NUDGE), &fms.g.throttle_nudge);
    param_link_variable(PARAM_ID(VEHICLE, USE_REV_THRUST), &fms.g.use_reverse_thrust);

    param_link_variable(PARAM_ID(VEHICLE, FS_SHORT_ACTN),    &fms.g.fs_action_short);
    param_link_variable(PARAM_ID(VEHICLE, FS_LONG_ACTN),     &fms.g.fs_action_long);
    param_link_variable(PARAM_ID(VEHICLE, FS_SHORT_TIMEOUT), &fms.g.fs_timeout_short);
    param_link_variable(PARAM_ID(VEHICLE, FS_LONG_TIMEOUT),  &fms.g.fs_timeout_long);
    param_link_variable(PARAM_ID(VEHICLE, FS_GCS_ENABL),     &fms.g.gcs_heartbeat_fs_enabled);

    param_link_variable(PARAM_ID(VEHICLE, MAN_EXPO_ROLL),   &fms.g.man_expo_roll);
    param_link_variable(PARAM_ID(VEHICLE, MAN_EXPO_PITCH),  &fms.g.man_expo_pitch);
    param_link_variable(PARAM_ID(VEHICLE, MAN_EXPO_RUDDER), &fms.g.man_expo_rudder);

    param_link_variable(PARAM_ID(VEHICLE, RUDDER_ONLY),     &fms.g.rudder_only);
    param_link_variable(PARAM_ID(VEHICLE, HOME_RESET_ALT),  &fms.g.home_reset_threshold);
    param_link_variable(PARAM_ID(VEHICLE, FLIGHT_OPTIONS),  &fms.g.flight_options);
    param_link_variable(PARAM_ID(VEHICLE, RTL_AUTOLAND),    &fms.g.rtl_autoland);
    param_link_variable(PARAM_ID(VEHICLE, RUDD_DT_GAIN),    &fms.g.rudd_dt_gain);

    param_link_variable(PARAM_ID(VEHICLE, TKOFF_THR_MINSPD),  &fms.g.takeoff_throttle_min_speed);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_THR_MINACC),  &fms.g.takeoff_throttle_min_accel);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_THR_DELAY),   &fms.g.takeoff_throttle_delay);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_TDRAG_ELEV),  &fms.g.takeoff_tdrag_elevator);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_TDRAG_SPD1),  &fms.g.takeoff_tdrag_speed1);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_ROTATE_SPD),  &fms.g.takeoff_rotate_speed);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_THR_SLEW),    &fms.g.takeoff_throttle_slewrate);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_PLIM_SEC),    &fms.g.takeoff_pitch_limit_reduction_sec);
    param_link_variable(PARAM_ID(VEHICLE, TKOFF_FLAP_PCNT),   &fms.g.takeoff_flap_percent);

    param_link_variable(PARAM_ID(VEHICLE, MIXING_GAIN),       &fms.g.mixing_gain);
    param_link_variable(PARAM_ID(VEHICLE, MIXING_OFFSET),     &fms.g.mixing_offset);

    param_link_variable(PARAM_ID(VEHICLE, DSPOILER_CROW_W1),  &fms.g.crow_flap_weight_outer);
    param_link_variable(PARAM_ID(VEHICLE, DSPOILER_CROW_W2),  &fms.g.crow_flap_weight_inner);
    param_link_variable(PARAM_ID(VEHICLE, DSPOILER_OPTS),     &fms.g.crow_flap_options);
    param_link_variable(PARAM_ID(VEHICLE, DSPOILER_AILMTCH),  &fms.g.crow_flap_aileron_matching);

    param_link_variable(PARAM_ID(VEHICLE, DSPOILR_RUD_RATE),  &fms.g.dspoiler_rud_rate);

    param_link_variable(PARAM_ID(VEHICLE, MANUAL_RCMASK),     &fms.g.manual_rc_mask);

    param_link_variable(PARAM_ID(VEHICLE, FWD_BAT_VOLT_MAX),  &fms.g.fwd_thr_batt_voltage_max);
    param_link_variable(PARAM_ID(VEHICLE, FWD_BAT_VOLT_MIN),  &fms.g.fwd_thr_batt_voltage_min);
    param_link_variable(PARAM_ID(VEHICLE, FWD_BAT_IDX),       &fms.g.fwd_thr_batt_idx);

    param_link_variable(PARAM_ID(VEHICLE, ALT_OFFSET),        &fms.g.alt_offset);
    param_link_variable(PARAM_ID(VEHICLE, ACRO_ROLL_RATE),    &fms.g.acro_roll_rate);
    param_link_variable(PARAM_ID(VEHICLE, ACRO_PITCH_RATE),   &fms.g.acro_pitch_rate);
    param_link_variable(PARAM_ID(VEHICLE, ACRO_YAW_RATE),     &fms.g.acro_yaw_rate);
    param_link_variable(PARAM_ID(VEHICLE, ACRO_LOCKING),      &fms.g.acro_locking);

    param_link_variable(PARAM_ID(VEHICLE, FLAP_1_PERCNT),     &fms.g.flap_1_percent);
    param_link_variable(PARAM_ID(VEHICLE, FLAP_1_SPEED),      &fms.g.flap_1_speed);
    param_link_variable(PARAM_ID(VEHICLE, FLAP_2_PERCNT),     &fms.g.flap_2_percent);
    param_link_variable(PARAM_ID(VEHICLE, FLAP_2_SPEED),      &fms.g.flap_2_speed);

    param_link_variable(PARAM_ID(VEHICLE, FLAP_SLEWRATE),     &fms.g.flap_slewrate);
    param_link_variable(PARAM_ID(VEHICLE, CRASH_ACC_THRESH),  &fms.g.crash_accel_threshold);

    param_link_variable(PARAM_ID(VEHICLE, KFF_RDDRMIX),       &fms.g.kff_rudder_mix);
    param_link_variable(PARAM_ID(VEHICLE, KFF_THR2PTCH),      &fms.g.kff_throttle_to_pitch);
    param_link_variable(PARAM_ID(VEHICLE, GROUND_STEER_ALT),  &fms.g.ground_steer_alt);
    param_link_variable(PARAM_ID(VEHICLE, GROUND_STEER_DPS),  &fms.g.ground_steer_dps);
    param_link_variable(PARAM_ID(VEHICLE, STAB_PITCH_DOWN),   &fms.g.stab_pitch_down);
}
/*------------------------------------test------------------------------------*/


